const person = {
    name: "tome",
    sayName: function() {
        console.log('this is ', this.name);
    },
    sayName2: () => {
        // es6箭头函数未对this进行处理，没有机制，未找到
        console.log('this is ', this.name);
    },
    sayNameAsync: function() {
        //es5中对this指向需要变量赋值，否则无法访问外部变量
        const _this = this;
        setTimeout(function() {
            console.log("name", _this.name); //name  tome
        }, 2000);
        // es6 的thisz指向外部申明变量
        setTimeout(() => {
            console.log('name2', this.name); //name tome 
        }, 2000)
    }
}

console.log(person.sayName()); //this is  tome
console.log(person.sayName2()); //this is  undefined
console.log(person.sayNameAsync());